$(function () {

})
/**
 * Created by King_Vicent on 2018/7/17.
 */
var vm = new Vue({
    el: '#rrapp',
    data:function() {
        return {
            deptQuestionTable: [],//督察单位统计列表数据
            deptQuestionPageNo: 1, // 当前页
            deptQuestionTotalPage: 0, // 总页数
            deptQuestionPageSize: 10, // 每页数据条数
            questionTable: [],//督察单位统计列表数据
            questionPageNo: 1, // 当前页
            questionTotalPage: 0, // 总页数
            questionPageSize: 10, // 每页数据条数
            deptSTime:'',
            qSTime:'',
            deptETime:'',
            qETime:'',
            props: {
                children: 'children',
                label: 'name',
                value:'xzqhId'
            },
            options1:[],
            options2:[],
            qhId1:['1'],
            qhIdValue:'1',
            qhId2:['1'],
            qhIdValue:'1',
            options3:[{value:'1',label:'派出所'}],
            zxdwValue:'1',

        }

    },
    mounted:function() {
        this.getDeptQuestionTableDatas();
        this.getQuestionTableDatas();
        this.getXzqhTreeList();
    },
   methods: {

         // 分页
       deptQuestionPageChange: function () {
           vm.getDeptQuestionTableDatas();
       },
       //序号
       /*indexMethod:function(index){
           return (vm.pageNo - 1) * vm.pageSize + (index + 1);
       },*/

        //获取列表数据
        getDeptQuestionTableDatas:function(){

            var params = {
                page: this.deptQuestionPageNo,
                xzqhId: this.qhId1[this.qhId1.length-1],
                deptETime:this.deptETime != '' ? dateFtt('yyyy-MM-dd', this.deptETime):'',
                deptSTime:this.deptSTime != '' ? dateFtt('yyyy-MM-dd', this.deptSTime):''
            }
            $.ajax({
                type: "GET",
                url: baseURL + 'business/statisial/deptlist',
                data: params,
                contentType: "application/json",
                success: function (res) {
                    if (res.code === '0') {
                        vm.deptQuestionTable = res.page.list
                        vm.deptQuestionTotalPage = res.page.totalPage
                        vm.deptQuestionPageNo = res.page.currPage
                    } else {
                        alert(res.msg);
                    }
                }
            });
        },

    //问题列表分页
        questionPageChange: function () {
              vm.getQuestionTableDatas();
          },
          //序号
          questionIndexMethod:function(index){
              return (vm.questionPageNo - 1) * vm.questionPageSize + (index + 1);
          },
           //获取列表数据
           getQuestionTableDatas:function(){

               var params = {
                     page: this.questionPageNo,
                     xzqhId: this.qhId2[this.qhId2.length-1],
                     qETime:this.qETime != '' ? dateFtt('yyyy-MM-dd', this.qETime):'',
                     qSTime:this.qSTime != '' ? dateFtt('yyyy-MM-dd', this.qSTime):''
               }
               $.ajax({
                   type: "GET",
                   url: baseURL + 'business/statisial/questionlist',
                   data: params,
                   contentType: "application/json",
                   success: function (res) {
                       if (res.code === '0') {
                            vm.questionTable = res.page.list
                            vm.questionTotalPage = res.page.totalPage
                            vm.questionPageNo = res.page.currPage

                       } else {
                           alert(res.msg);
                       }
                   }
               });
           },

        formatMath:function (row, column) {
            if(row.qnum == 0 || row.qnum == '' || row.qnum == null || row.allnum == 0){
                return "0%";
            }
            return row.qnum == 0 ? "0%" : Math.round(row.qnum / row.allnum * 10000) / 100.00 + "%";
        },

        getXzqhTreeList:function(){
            $.ajax({
               type: "GET",
               url: baseURL + 'business/statisial/getXzqhTreeList',
               contentType: "application/json",
               success: function (res) {
                   if (res.code === '0') {
                        var object = res.data
                        for (var i= 0;i<object[0].children.length;i++){
                            var o = object[0].children[i];
                            for(var j = 0;j<o.children.length;j++){
                                var c = o.children[j];
                                if(c.children.length == 0 ){
                                    delete c.children;
                                }
                            }
                        }
                       vm.options1 = object;
                       vm.options2 = object;
                   } else {
                       alert(res.msg);
                   }
               },

           });
        },


        handleChange1:function(value){
                    console.log(value);
                    console.log(vm.qhIdValue);
                    console.log(vm.qhId1[vm.qhId1.length-1]);
                    vm.getDeptQuestionTableDatas();

           /*vm.qhIdValue = value[value.length-1];
           console.log(vm.qhIdValue);
           vm.getDeptQuestionTableDatas();*/
        },
         handleChange2:function(value){

            vm.getQuestionTableDatas();
        },



    },

})
